const { plu_api_linkjs, plu_ga, querySql, op } = require("../../middleware/baseModel");

module.exports = {
  "GET /config/v1": async (ctx, next) => {
    const res = await plu_api_linkjs.findAll({ where: {} });
    return ctx.success(res);
  },

  "GET /config/v2": async (ctx, next) => {
    let data = [
      { platformUrl: "sycm.taobao.com", linkUrl: "https://yunzhuan.light120.com/platform_test/businessStaff/index.js" },
      { platformUrl: "market.m.taobao.com", linkUrl: "https://yunzhuan.light120.com/platform_test/tbLive/index.js", inline: true },
      { platformUrl: "databank.tmall.com", linkUrl: "https://yunzhuan.light120.com/platform_test/databank/index.js", inline: true },
    ];
    return ctx.success(data);
  },

  "GET /config/ga": async (ctx, next) => {
    let ip = ctx.getIp();
    let { title, brand, type, postion, parentSelector: parent_selector, className: class_name, icon, path, browser } = ctx.getQuery();
    let res = await plu_ga.create({ title, type, brand, postion, parent_selector, class_name, icon, path, ip, browser });
    return ctx.success(res);
  },
};
